package net.melon.sysres.inst.struts2;

import net.esj.basic.core.engine.config.MelonConfig;
import net.esj.basic.core.engine.util.tree.TreeConverter;
import net.esj.basic.core.engine.util.tree.VoTreeConverter;
import net.esj.basic.plugins.view.FacadeAware;
import net.esj.basic.utils.Validators;
import net.esj.basic.view.PageAction;
import net.melon.sysres.Constants;

public abstract class AbstractSysresAction<P, V> extends PageAction<P, V> implements Constants,FacadeAware{

	private String template;
	private String theme;
	private String namespace;
	private boolean ajax = true;
	
	public String getTemplate() {
		return template;
	}


	public void setTemplate(String template) {
		this.template = template;
	}


	public String getTheme() {
		return theme;
	}


	public void setTheme(String theme) {
		this.theme = theme;
	}


	public String getNamespace() {
		return namespace;
	}


	public void setNamespace(String namespace) {
		this.namespace = namespace;
	}

	public boolean isAjax() {
		return ajax;
	}


	public void setAjax(boolean ajax) {
		this.ajax = ajax;
	}

	@Override
	protected String[] getDefaultSources() {
		String str  = MelonConfig.getProperty(DEFAULT_MELON_MESSAGE);
		if(Validators.isEmpty(str)){
			return null;
		}
		return new String[]{str};
	}
	
	protected TreeConverter findTreeConverter(){
		String res = MelonConfig.getProperty(MELON_SYS_TREE_CONVERTER,DEFAULT_SYS_TREE_CONVERTER);
		try {
			Class clazz = Class.forName(res);
			return (TreeConverter) clazz.newInstance();
		} catch (Exception e) {
			return new VoTreeConverter();
		}
	}
	
}
